/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package top.dzygod.modules.oa.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import top.dzygod.modules.system.domain.User;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;
import java.util.Set;

/**
* @website https://dzygod.top
* @description /
* @author dzyGod
* @date 2020-06-17
**/
@Entity
@Getter
@Setter
@Table(name="oa_group")
public class Group implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "group_id")
    @ApiModelProperty(value = "主键")
    private Long id;

    @Column(name = "group_name")
    @ApiModelProperty(value = "名称")
    private String groupName;

/*
    @OneToMany(mappedBy = "group",targetEntity = Project.class)
    @ApiModelProperty(value = "分组", hidden = true)
    private Set<Project> projects;
*/

    @Column(name = "gmt_create")
    @CreationTimestamp
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Timestamp gmtCreate;

    @Column(name = "gmt_modified")
    @UpdateTimestamp
    @ApiModelProperty(value = "修改时间")
    private Timestamp gmtModified;

    @Column(name = "enabled")
    @ApiModelProperty(value = "激活状态")
    private Boolean enabled;


    public void copy(Group source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
